<style lang="less" scoped>
.list-wrapper {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: rgba(0, 0, 0, 0.2);
  .tab-nav {
    margin: 20px 20px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.3);
  }
}
.led-list {
  flex: 1;
  overflow: auto;
  padding: 20px;
}
.tb-oper-dropdown-menu {
  margin-top: 0 !important;
}
</style>
<template>
  <div class="list-wrapper">
    <div class="tab-nav">
      <a
        href="javascript:;"
        class="item"
        :class="{ active: item.key == type }"
        @click="changeType(item)"
        v-for="(item, index) in typeList"
        :key="index"
        v-if="item.visible"
        >{{ item.name }}</a
      >
    </div>
    <div class="led-list">
      <div class="mb-20" v-if="type == 'ip'">
        <el-button
          v-if="type == 'ip' && hasPermission('013001001')"
          type="blue"
          @click="uploadIP"
          :disabled="!$store.getters.hasEditPermission"
          ><i class="iconfont icon-upload fs-14"></i> 上传IP音柱</el-button
        >
        <!-- <el-button type="green" @click="publishIPAction"><i class="iconfont icon-publish fs-16"></i> 发布IP音柱</el-button> -->
        <el-button
          v-if="hasPermission('013001002')"
          type="blue"
          :disabled="multipleSelection.length == 0"
          @click="playAllIPAction()"
          >批量播放</el-button
        >
        <el-button
          v-if="hasPermission('013001003')"
          type="blue"
          :disabled="multipleSelection.length == 0"
          @click="stopPlayAllIPAction()"
          >批量终止播放</el-button
        >
        <!-- <el-button type="blue" :disabled="multipleSelection.length==0" :loading="ipSettingVolume" @click="setAllIPVolumeAction()">批量设置音量</el-button> -->
      </div>
      <div class="mb-20" v-if="type == 'led'">
        <el-button
          v-if="hasPermission('013002001')"
          type="blue"
          @click="uploadLed"
          :disabled="!$store.getters.hasEditPermission"
          ><i class="iconfont icon-upload fs-14"></i> 上传</el-button
        >
        <el-dropdown
          v-if="hasPermission('013002002')"
          class="ml-10 mr-10"
          type="primary"
          size="small"
        >
          <el-button type="green" :disabled="multipleSelection.length == 0">
            <i class="iconfont icon-publish fs-16"></i> 批量发布<i
              class="el-icon-arrow-down el-icon--right"
            ></i>
          </el-button>
          <el-dropdown-menu class="tb-oper-dropdown-menu" slot="dropdown">
            <el-dropdown-item
              ><el-button type="green" @click="publishAllAction('video')"
                >视频</el-button
              ></el-dropdown-item
            >
            <el-dropdown-item class="mt-10"
              ><el-button type="green" @click="publishAllAction('text')"
                >文字</el-button
              ></el-dropdown-item
            >
            <el-dropdown-item class="mt-10"
              ><el-button type="green" @click="publishAllAction('image')"
                >图片</el-button
              ></el-dropdown-item
            >
          </el-dropdown-menu>
        </el-dropdown>
        <el-button
          v-if="hasPermission('013002003')"
          type="blue"
          :disabled="
            multipleSelection.length == 0 || !$store.getters.hasEditPermission
          "
          @click="stopPlayAllAction()"
          >批量停止播放</el-button
        >
        <el-button
          v-if="hasPermission('013002004')"
          type="blue"
          :disabled="
            multipleSelection.length == 0 || !$store.getters.hasEditPermission
          "
          @click="startPlayAllAction()"
          >批量开始播放</el-button
        >
      </div>

      <div v-if="type == 'monitor'">
        <el-table :data="dataList" style="width: 100%" v-loading="loading">
          <el-table-column
            type="index"
            label="序号"
            width="90"
          ></el-table-column>
          <el-table-column prop="number" label="设备编号"></el-table-column>
          <el-table-column prop="name" label="设备名称"></el-table-column>
          <el-table-column prop="areaName" label="设备类型">
            <template slot-scope="scope">
              {{ deviceType[scope.row.deviceClassify] }}
            </template>
          </el-table-column>
          <el-table-column prop="position" label="安装位置"></el-table-column>
        </el-table>
      </div>

      <el-table
        :data="dataList"
        style="width: 100%"
        v-loading="loading"
        @selection-change="handleSelectionChange"
        v-else
      >
        <el-table-column type="selection" width="55"></el-table-column>
        <el-table-column type="index" label="序号" width="90"></el-table-column>
        <el-table-column prop="number" label="设备编号"></el-table-column>
        <el-table-column prop="name" label="设备名称"></el-table-column>
        <el-table-column prop="areaName" label="设备类型">
          <template slot-scope="scope">
            {{ deviceType[scope.row.deviceClassify] }}
          </template>
        </el-table-column>
        <el-table-column prop="position" label="安装位置"></el-table-column>
        <el-table-column label="操作" :width="type == 'led' ? 400 : 400">
          <template slot-scope="scope">
            <div class="nowrap" v-if="scope.row.deviceClassify == 8">
              <el-dropdown
                class="ml-10 mr-10"
                type="primary"
                size="small"
                v-if="
                  hasPermission('013002005') ||
                  hasPermission('013002006') ||
                  hasPermission('013002007') ||
                  hasPermission('013002008')
                "
              >
                <el-button
                  type="green"
                  :disabled="!$store.getters.hasEditPermission"
                  >发布<i class="el-icon-arrow-down el-icon--right"></i
                ></el-button>
                <el-dropdown-menu class="tb-oper-dropdown-menu" slot="dropdown">
                  <el-dropdown-item v-if="hasPermission('013002006')"
                    ><el-button
                      type="green"
                      @click="publishAction(scope.row, 'video')"
                      >视频</el-button
                    ></el-dropdown-item
                  >
                  <el-dropdown-item
                    v-if="hasPermission('013002007')"
                    class="mt-10"
                    ><el-button
                      type="green"
                      @click="publishAction(scope.row, 'text')"
                      >文字</el-button
                    ></el-dropdown-item
                  >
                  <el-dropdown-item
                    v-if="hasPermission('013002008')"
                    class="mt-10"
                    ><el-button
                      type="green"
                      @click="publishAction(scope.row, 'image')"
                      >图片</el-button
                    ></el-dropdown-item
                  >
                </el-dropdown-menu>
              </el-dropdown>
              <el-button
                v-if="hasPermission('013002009')"
                type="primary"
                @click="stopPlayAction(scope.row)"
                :disabled="!$store.getters.hasEditPermission"
                >停止播放</el-button
              >
              <el-button
                v-if="hasPermission('013002010')"
                type="primary"
                @click="startPlayAction(scope.row)"
                :disabled="!$store.getters.hasEditPermission"
                >开始播放</el-button
              >
            </div>
            <div class="nowrap" v-else>
              <el-button
                v-if="hasPermission('013001004')"
                type="primary"
                @click="playIPAction(scope.row)"
                :disabled="!$store.getters.hasEditPermission"
                >播放</el-button
              >
              <el-button
                v-if="hasPermission('013001005')"
                type="primary"
                :loading="ipStoping"
                @click="stopPlayIPAction(scope.row)"
                :disabled="!$store.getters.hasEditPermission"
                >终止播放</el-button
              >
              <el-button
                v-if="hasPermission('013001006')"
                type="primary"
                :loading="ipStoping"
                @click="setIPVolumeAction(scope.row)"
                :disabled="!$store.getters.hasEditPermission"
                >设置音量</el-button
              >
              <el-button
                v-if="hasPermission('013001007')"
                type="primary"
                @click="monitorAction(scope.row)"
                :disabled="!$store.getters.hasEditPermission"
                >监听</el-button
              >
              <el-button
                v-if="hasPermission('013001008')"
                type="primary"
                @click="stopMonitorAction(scope.row)"
                :disabled="!$store.getters.hasEditPermission"
                >停止监听</el-button
              >
            </div>
          </template>
        </el-table-column>
      </el-table>
    </div>

    <!-- 上传弹窗 start -->
    <el-dialog
      v-if="uploadModalVisible"
      :title="uploadTitle"
      :visible.sync="uploadModalVisible"
      width="500px"
      :close-on-click-modal="false"
      :close-on-press-escape="false"
      destroy-on-close
    >
      <el-form label-width="100px">
        <el-form-item label="文件：">
          <el-upload
            ref="upload"
            class="upload-file"
            :action="uploadUrl"
            :file-list="fileList"
            :limit="1"
            :on-success="handleUploadSuccess"
            :on-remove="handleRemove"
            :auto-upload="false"
            :data="uploadData"
            :accept="accept"
            :before-upload="beforeFileUpload"
            name="file"
            :disabled="!$store.getters.hasEditPermission"
          >
            <el-button size="small" type="green">点击上传</el-button>
          </el-upload>
        </el-form-item>
      </el-form>
      <div slot="footer">
        <el-button type="cancel" @click="uploadModalVisible = false"
          >取消</el-button
        >
        <el-button
          type="primary"
          :loading="uploading"
          @click="submitUpload"
          :disabled="!$store.getters.hasEditPermission"
          >确定</el-button
        >
      </div>
    </el-dialog>
    <!-- 上传弹窗 end -->
    <!-- 设置音量 start -->
    <el-dialog
      v-if="volumeModalVisible"
      title="设置音量"
      :visible.sync="volumeModalVisible"
      width="500px"
      :close-on-click-modal="false"
      :close-on-press-escape="false"
      destroy-on-close
    >
      <el-form label-width="100px">
        <el-form-item label="当前音量：">{{ ipVolume }}</el-form-item>
        <el-form-item label="音量：">
          <el-slider v-model="ipVolume" :min="0" :max="100"></el-slider>
        </el-form-item>
      </el-form>
      <div slot="footer">
        <el-button type="cancel" @click="volumeModalVisible = false"
          >取消</el-button
        >
        <el-button
          type="primary"
          :loading="uploading"
          @click="doSetIpVolume"
          :disabled="!$store.getters.hasEditPermission"
          >确定</el-button
        >
      </div>
    </el-dialog>
    <!-- 设置音量 end -->
    <!-- 发布 IP音柱 start -->
    <el-dialog
      v-if="publishIPModalVisible"
      title="已上传IP音柱"
      :visible.sync="publishIPModalVisible"
      width="500px"
      :close-on-click-modal="false"
      :close-on-press-escape="false"
      destroy-on-close
    >
      <el-table :data="IPList" style="width: 100%" v-loading="loading">
        <el-table-column prop="filename" label="名称"></el-table-column>
        <!-- <el-table-column prop="filepath" label="路径"> </el-table-column> -->
        <el-table-column label="操作" width="160">
          <template slot-scope="scope">
            <el-button
              type="green"
              :loading="publishing"
              @click="publishIP(scope.row)"
              :disabled="!$store.getters.hasEditPermission"
              >发布</el-button
            >
          </template>
        </el-table-column>
      </el-table>
    </el-dialog>
    <!-- 发布 IP音柱 end -->
    <!-- 播放弹窗 start -->
    <el-dialog
      v-if="playModalVisible"
      title="播放"
      :visible.sync="playModalVisible"
      width="400px"
      :close-on-click-modal="false"
      :close-on-press-escape="false"
      destroy-on-close
    >
      <audioPlay
        ref="audioPlay"
        :activeDeviceNumbers="activeDeviceNumbers"
        @submitting="playing = true"
        @fail="playing = false"
        @success="playAudioSuccess"
      />
      <div slot="footer">
        <el-button type="cancel" @click="playModalVisible = false"
          >取消</el-button
        >
        <el-button
          type="primary"
          :loading="playing"
          @click="doPlayAudio"
          :disabled="!$store.getters.hasEditPermission"
          >播放</el-button
        >
      </div>
    </el-dialog>
    <!-- 播放弹窗 end -->
    <!-- 监听弹窗 start -->
    <el-dialog
      v-if="monitorModalVisible"
      title="选择监听设备"
      :visible.sync="monitorModalVisible"
      width="400px"
      :close-on-click-modal="false"
      :close-on-press-escape="false"
      destroy-on-close
    >
      <monitor
        ref="monitor"
        :activeDevice="activeDevice"
        :companyIds="companyIds"
        @submitting="monitoring = true"
        @fail="monitoring = false"
        @success="monitorSuccess"
      />
      <div slot="footer">
        <el-button type="cancel" @click="monitorModalVisible = false"
          >取消</el-button
        >
        <el-button
          type="primary"
          :loading="monitoring"
          @click="doMonitor"
          :disabled="!$store.getters.hasEditPermission"
          >监听</el-button
        >
      </div>
    </el-dialog>
    <!-- 监听弹窗 end -->
    <!-- 播放 start -->
    <el-dialog
      v-if="doPlayIPModalVisible"
      title="播放IP音柱"
      :visible.sync="doPlayIPModalVisible"
      width="500px"
      :close-on-click-modal="false"
      :close-on-press-escape="false"
      destroy-on-close
      append-to-body
    >
      <el-form label-width="100px" ref="playIPForm" :model="playIPForm">
        <el-form-item label="设备编号：">{{
          this.activeDeviceNumbers.join(",")
        }}</el-form-item>
        <el-form-item label="文件编号：">{{
          activeFile && activeFile.filenumber
        }}</el-form-item>
        <!-- <el-form-item label="开始时间：" prop="starttime" :rules="[{ required: true, message: '请输入开始时间' }]">
                    <el-input placeholder="请输入" v-model.trim="playIPForm.starttime"></el-input>
                </el-form-item>
                <el-form-item label="结束时间：" prop="endtime" :rules="[{ required: true, message: '请输入结束时间' }]">
                    <el-input placeholder="请输入" v-model.trim="playIPForm.endtime"></el-input>
                </el-form-item> -->
        <el-form-item
          label="起始时间："
          prop="starttime"
          :rules="[{ required: true, message: '请选择起始时间' }]"
        >
          <el-date-picker
            v-model="playDatetimeRange"
            type="datetimerange"
            range-separator="至"
            start-placeholder="开始时间"
            end-placeholder="结束时间"
            format="yyyy-MM-dd HH:mm:ss"
            value-format="yyyy-MM-dd HH:mm:ss"
            style="width: 100%"
          >
          </el-date-picker>
        </el-form-item>
      </el-form>
      <div slot="footer">
        <el-button type="cancel" @click="doPlayIPModalVisible = false"
          >取消</el-button
        >
        <el-button
          type="primary"
          :loading="playing"
          @click="doPlayIP"
          :disabled="!$store.getters.hasEditPermission"
          >播放</el-button
        >
      </div>
    </el-dialog>
    <!-- 播放 end -->
    <!-- LED 发布 start -->
    <el-dialog
      v-if="publishLedModalVisible"
      :title="publishLedTitle"
      :visible.sync="publishLedModalVisible"
      width="500px"
      :close-on-click-modal="false"
      :close-on-press-escape="false"
      destroy-on-close
      append-to-body
    >
      <publish
        ref="ledPublish"
        :type="activePublishLedType"
        :activeDeviceNumbers="activeDeviceNumbers"
        @submitting="publishing = true"
        @fail="publishing = false"
        @success="publishLedSuccess"
      ></publish>
      <div slot="footer">
        <el-button type="cancel" @click="publishLedModalVisible = false"
          >取消</el-button
        >
        <el-button
          type="primary"
          :loading="publishing"
          @click="publishLed"
          :disabled="!$store.getters.hasEditPermission"
          >发布</el-button
        >
      </div>
    </el-dialog>
    <!-- LED 发布 end -->
  </div>
</template>
<script>
let isLock = false;
import { mapState } from "vuex";
import publish from "@/components/led/publish.vue";
import audioPlay from "@/components/led/audioPlay.vue";
import monitor from "@/components/led/monitorDevice.vue";
export default {
  name: "Led",
  components: { publish, audioPlay, monitor },
  props: {
    companyId: {
      type: String,
      default: "",
    },
    companyIds: {
      type: Array,
      default() {
        return [];
      },
    },
    // type: {
    // 	type: String,
    // 	default: ''
    // }
  },
  data() {
    return {
      total: 0,
      currentPage: 1,
      pageSize: 10,
      loading: false,
      dataList: [],
      multipleSelection: [],
      uploadModalVisible: false,
      uploadUrl: "",
      IPuploadUrl:
        this.config.baseApi + "/fireFightingIOT/ipbroadcast/uploadMusic", //'/uploadFile/ipAudioOrLedVideoUpload',
      ledUploadUrl: this.config.baseApi + "/uploadFile/ipAudioOrLedVideoUpload",
      uploadTitle: "",
      uploadType: "",
      fileList: [],
      uploadData: {
        homeId: "",
        deviceClassify: "",
      },
      uploading: false,
      deviceType: {
        6: "鹰眼e通",
        8: "LED屏",
        9: "IP音柱",
      },
      typeList: [
        {
          id: "9",
          name: "IP音柱",
          key: "ip",
          visible: this.hasPermission("013001"),
        },
        {
          id: "8",
          name: "LED屏",
          key: "led",
          visible: this.hasPermission("013002"),
        },
        {
          id: "6",
          name: "摄像头",
          key: "monitor",
          visible: true,
        },
      ],
      type: "ip", //选中的设备类型
      publishIPModalVisible: false,
      publishing: false,
      playIPModalVisible: false,
      doPlayIPModalVisible: false,
      playing: false,
      playDatetimeRange: [],
      playIPForm: {
        devicenumber: "",
        filenumber: "",
        starttime: "",
        endtime: "",
      },
      ipStoping: false,
      IPList: [],
      activeDevice: null,
      activeDeviceNumbers: [],
      activeFile: null,
      publishLedModalVisible: false,
      publishLedTitle: "",
      activePublishLedType: "",
      deleting: false,
      ipSettingVolume: false,
      volumeModalVisible: false,
      ipVolume: 0,
      playModalVisible: false,
      playing: false,
      monitorModalVisible: false,
      monitoring: false,
    };
  },
  watch: {
    companyIds() {
      if (this.companyIds.length > 0) {
        this.getData();
      }
    },
    playDatetimeRange(val) {
      this.playIPForm.starttime = val[0];
      this.playIPForm.endtime = val[1];
    },
  },
  computed: {
    ...mapState(["scale", "siteInfos"]),
    mainH() {
      return this.winH - 200;
    },
    deviceClassify() {
      if (this.type == "ip") return 9;
      if (this.type == "led") return 8;
      if (this.type == "monitor") return 6;
      return "";
    },
    accept() {
      if (this.uploadType == "led") {
        return ".mp4,.jpg";
      } else {
        return ".mp3";
      }
    },
    selectedDeviceNumbers() {
      return this.multipleSelection.map((item) => item.number);
    },
  },
  methods: {
    stopMonitorAction(item) {
      this.$post("/fireFightingIOT/ipbroadcast/stopMonitor", {
        monitoreddevid: item.id,
      }).then(
        (res) => {
          this.$message.success("操作成功");
        },
        (err) => {
          this.$message.error(err.msg);
        }
      );
    },
    monitorSuccess() {
      this.activeDevice = null;
      this.monitorModalVisible = false;
      this.$message.success("操作成功");
    },
    doMonitor() {
      this.$refs.monitor.submitAction();
    },
    monitorAction(item) {
      this.activeDevice = item;
      this.monitorModalVisible = true;
    },
    doPlayAudio() {
      this.$refs.audioPlay.submitAction();
    },
    playAudioSuccess() {
      this.playModalVisible = false;
      this.getData();
    },
    changeType(item) {
      this.type = item.key;
      this.getData();
    },
    beforeFileUpload(file) {
      const isLtIP = file.size / 1024 / 1024 < 200;
      const isLtLED = file.size / 1024 / 1024 < 50;

      if (this.uploadType == "led" && !isLtLED) {
        this.$message.error("视频大小不能超过 50MB!");
      }
      if (this.uploadType == "ip" && !isLtIP) {
        this.$message.error("音频大小不能超过 200MB!");
      }
      return (
        (this.uploadType == "led" && isLtLED) ||
        (this.uploadType == "ip" && isLtIP)
      );
    },
    publishIPAction() {
      this.IPList = [];
      this.publishIPModalVisible = true;
      this.getIPList(1);
    },
    publishIP(item) {
      this.publishing = true;
      this.$post("/fireFightingIOT/iPSound/uploadMediaFile", {
        id: item.id,
        filePath: item.filepath,
        fileName: item.filename,
        homeId: this.siteInfos.homeId,
      }).then(
        (res) => {
          this.publishing = false;
          this.$message.success("发布成功");
          this.getIPList(1);
        },
        (err) => {
          this.publishing = false;
          this.$message.error(err.msg);
        }
      );
    },
    playIPAction(item) {
      this.activeDeviceNumbers = [item.number];
      this.playModalVisible = true;
      this.playing = false;
    },
    playAllIPAction() {
      this.activeDeviceNumbers = this.selectedDeviceNumbers;
      this.playModalVisible = true;
      this.playing = false;
    },
    playIP(item) {
      this.activeFile = item;
      this.doPlayIPModalVisible = true;
    },
    doPlayIP() {
      this.$refs["playIPForm"].validate((valid) => {
        if (valid) {
          let playIPForm = Object.assign(this.playIPForm, {
            devicenumber: this.activeDeviceNumbers.join(","),
            filenumber: this.activeFile.filenumber,
          });
          this.playing = true;
          this.$post("/fireFightingIOT/iPSound/publishAudio", playIPForm).then(
            (res) => {
              this.playing = false;
              // this.$message.success('操作成功')
              this.doPlayIPModalVisible = false;
              this.playIPModalVisible = false;
              this.$alert(
                "文件 " + this.activeFile.filename + " 播放成功",
                "操作成功",
                {
                  confirmButtonText: "知道了",
                }
              );
            },
            (err) => {
              this.playing = false;
              this.$message.error(err.msg);
            }
          );
        }
      });
    },
    stopPlayIPAction(item) {
      this.doStopPlayIP([item.number]);
    },
    stopPlayAllIPAction() {
      this.doStopPlayIP(this.selectedDeviceNumbers);
    },
    doStopPlayIP(nubmers) {
      this.ipStoping = true;
      this.$post("/fireFightingIOT/ipbroadcast/stopMusic", {
        deviceidarray: nubmers,
      }).then(
        (res) => {
          this.ipStoping = false;
          this.$message.success("操作成功");
        },
        (err) => {
          this.ipStoping = false;
          this.$message.error(err.msg);
        }
      );
    },
    setIPVolumeAction(item) {
      this.$post("/fireFightingIOT/iPSound/showDeviceVolume", {
        deviceNumber: item.number,
      }).then((res) => {
        this.activeDeviceNumbers = [item.number];
        this.ipVolume = +res.data.ledVolume;
        this.volumeModalVisible = true;
      });
    },
    setAllIPVolumeAction() {
      this.activeDeviceNumbers = this.selectedDeviceNumbers;
      this.ipVolume = 0;
      this.volumeModalVisible = true;
    },
    doSetIpVolume() {
      this.ipSettingVolume = true;
      this.$post("/fireFightingIOT/ipbroadcast/setvol", {
        deviceidarray: this.activeDeviceNumbers,
        vol: this.ipVolume,
      }).then(
        (res) => {
          this.ipSettingVolume = false;
          this.$message.success("设置成功");
          this.volumeModalVisible = false;
        },
        (err) => {
          this.ipSettingVolume = false;
          this.$message.error(err.msg);
        }
      );
    },
    getIPList(state, cbk) {
      this.$get("/fireFightingIOT/iPSound/publishOrPlayList", {
        state: state,
        homeId: this.siteInfos.homeId,
      }).then(
        (res) => {
          this.IPList = res.data;
        },
        (err) => {
          this.$message.error(err.msg);
        }
      );
    },
    uploadIP() {
      this.fileList = [];
      this.uploadType = "ip";
      this.uploadTitle = "上传IP音柱";
      this.uploadUrl = this.IPuploadUrl;
      this.uploadModalVisible = true;
      this.uploadData = {
        homeId: this.siteInfos.homeId,
        token: this.siteInfos.token,
      };
    },
    handleUploadSuccess(res, file) {
      if (res.code == 0) {
        this.$message.success("上传成功");
        this.uploadModalVisible = false;
        this.getData();
      } else {
        this.$message.error(res.msg);
      }
    },
    submitUpload() {
      this.$refs.upload.submit();
    },
    handleRemove(file, fileList) {},
    getData() {
      this.loading = true;
      this.$post("/fireFightingIOT/device/deviceListNew", {
        deviceClassify: this.deviceClassify,
        businessId:
          this.siteInfos.userType == 1 ? this.companyIds.join(",") : "",
      }).then(
        (res) => {
          this.loading = false;
          let data = res.data;
          this.dataList = data;
        },
        (err) => {
          this.loading = false;
          if (err.msg) {
            this.$message.error(err.msg);
          }
        }
      );
    },
    handleSelectionChange(val) {
      this.multipleSelection = val;
    },
    uploadLed() {
      this.fileList = [];
      this.uploadType = "led";
      this.uploadTitle = "上传LED";
      this.uploadUrl = this.ledUploadUrl;
      this.uploadModalVisible = true;
      this.uploadData = {
        homeId: this.siteInfos.homeId,
        token: this.siteInfos.token,
        deviceClassify: 8,
      };
    },
    publishAction(item, type) {
      this.activeDeviceNumbers = [item.number];
      this.publishLedModalVisible = true;
      let title = "";
      switch (type) {
        case "video":
          title = "发布视频";
          break;
        case "text":
          title = "发布文字";
          break;
        case "image":
          title = "发布图片";
          break;
      }
      this.publishLedTitle = title;
      this.activePublishLedType = type;
    },
    publishAllAction(type) {
      this.activeDeviceNumbers = this.selectedDeviceNumbers;
      this.publishLedModalVisible = true;
      let title = "";
      switch (type) {
        case "video":
          title = "发布视频";
          break;
        case "text":
          title = "发布文字";
          break;
        case "image":
          title = "发布图片";
          break;
      }
      this.publishLedTitle = title;
      this.activePublishLedType = type;
    },
    publishLed() {
      this.$refs.ledPublish.submitAction();
    },
    publishLedSuccess() {
      this.publishLedModalVisible = false;
      this.$message.success("发布成功");
      this.publishing = false;
    },
    startPlayAction(item) {
      this.doPlayVideo([item.number]);
    },
    startPlayAllAction() {
      this.doPlayVideo(this.selectedDeviceNumbers);
    },
    doPlayVideo(numbers) {
      this.$post("/fireFightingIOT/LEDScreen/play", {
        number: numbers.join(","),
      }).then(
        (res) => {
          this.$message.success("操作成功");
        },
        (err) => {
          this.$message.error(err.msg);
        }
      );
    },
    stopPlayAction(item) {
      this.doStopPlayVideo([item.number]);
    },
    stopPlayAllAction() {
      this.doStopPlayVideo(this.selectedDeviceNumbers);
    },
    doStopPlayVideo(numbers) {
      this.$post("/fireFightingIOT/LEDScreen/stopPlay", {
        number: numbers.join(","),
      }).then(
        (res) => {
          this.$message.success("操作成功");
        },
        (err) => {
          this.$message.error(err.msg);
        }
      );
    },
  },
  created() {
    this.getData();
  },
  activated() {},
  mounted() {},
};
</script>
